# _*_ encoding:utf-8 _*_
from django.contrib.auth.models import Group, Permission

from rest_framework.response import Response
from rest_framework.permissions import IsAdminUser
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializers.group_serializers import GroupModelSerializer
from meiduo_admin.serializers.perm_serializers import PermSimpleModelSerializer
from meiduo_admin.paginations import MyPage


class GroupViewSet(ModelViewSet):
    permission_classes = [IsAdminUser]

    queryset = Group.objects.all()
    serializer_class = GroupModelSerializer
    pagination_class = MyPage

    def get_simple_prem(self, request):
        queryset = Permission.objects.all()
        serializer = PermSimpleModelSerializer(queryset, many=True)

        return Response(serializer.data)










